const http = require('http');
const fs = require('fs');
const zlib = require('zlib');

let server = http.createServer((request, response) => {
	let rs = fs.createReadStream(`.${request.url}`);

	response.setHeader('content-encoding', 'gzip');
	let gz = zlib.createGzip();
	rs.pipe(gz).pipe(response);

	rs.on('error', function() {
		response.writeHead(404);
		response.write('404');

		response.end();
	})
})

server.listen(8080);